package cn.aion.util;

import cn.aion.model.ProjectVideo;

import java.util.Map;

/**
 *
 * Created by 虚空之翼 on 2017/1/3.
 */
public class Helper {
    public static String getMetaChannelId(Map<String, String> metas) {
        String channelId = "";
        for (String key : metas.keySet()) {
            if (key.equals("channelId")) {
                channelId = metas.get(key);
            }
        }
        return channelId;
    }

    public static Long casePlayTotal(String totalStr) {
        Double total = 0d;
        if (!totalStr.equals("")) {
            totalStr = totalStr.replaceAll(",", "").replace("人", "");
            if (totalStr.contains("万")) {
                total = Double.parseDouble(totalStr.replace("万", "")) * 10000;
            } else if (totalStr.contains("亿")){
                total = Double.parseDouble(totalStr.replace("亿", "")) * 10000 * 10000;
            } else {
                total = Double.parseDouble(totalStr);
            }
        }

        return Math.round(total);
    }

    public static int caseFansTotal(String totalStr) {
        Float total = 0f;
        if (!totalStr.equals("")) {
            totalStr = totalStr.replaceAll(",", "").replace("人", "");
            if (totalStr.contains("万")) {
                total = Float.parseFloat(totalStr.replace("万", "")) * 10000;
            } else if (totalStr.contains("亿")){
                total = Float.parseFloat(totalStr.replace("亿", "")) * 10000 * 10000;
            } else {
                total = Float.parseFloat(totalStr);
            }
        }

        return Math.round(total);
    }

    public static int getVideoTotal(ProjectVideo video) {
        int total = 0;
        total = video.getYoukuVv() + video.getIqiyiVv() + video.getQqVv() + video.getSohuVv() + video.getBilibiliVv()
                + video.getToutiaoVv() + video.getTudouVv() + video.getMeipaiVv() + video.getMiaopaiVv() + video.getAcfunVv() ;

        return total;
    }
}
